import request from '@/utils/request';

/**
 * 添加等级
 */
export async function addLevel(data) {
  const res = await request.post('/level/addLevel', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 等级列表
 */
export async function levelList(data) {
  const res = await request.post('level/levelList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 编辑等级
 */
export async function editLevel(data) {
  const res = await request.post('level/editLevel', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加会员卡密
 */
export async function addLevelCami(data) {
  const res = await request.post('level/addLevelCami', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 会员卡密列表
 */
export async function camiList(data) {
  const res = await request.post('level/camiList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除会员卡密
 */
export async function deleteCami(data) {
  const res = await request.post('level/deleteCami', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 会员购买记录
export async function userLevelOrderList(data) {
  const res = await request.post('level/userLevelOrderList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
